package com.huawei.appgallery.appcomment.ui.usercomment;

import android.content.Context;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RatingBar;
import android.widget.TextView;
import com.huawei.appgallery.appcomment.impl.bean.UserCommentInfoCardBean;
import com.huawei.appgallery.appcomment.impl.bean.UserCommentInfoCardBean.CommentInfo;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView.b;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView.e;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwTextView;
import o.azb;
import o.bcb;
import o.bcg;
import o.bcg.c;
import o.bcg.h;
import o.bei;
import o.ber;
import o.cea;
import o.cgy;
import o.cgz;
import o.ContentManager;

public class UserCommentInfoCard extends BaseDistCard implements b, e, OnClickListener {
    private ImageView ʻ;
    private LinearLayout ʻॱ;
    private ImageView ʼ;
    private ImageView ʽ;
    private TextView ˊॱ;
    private View ˋ;
    private TextView ˋˋ;
    private View ˋॱ;
    private TextView ˋᐝ;
    private TextView ˌ;
    private ImageView ˍ;
    private HwTextView ˎˎ;
    private View ˎˏ;
    private ImageView ˏˎ;
    private TextView ˏˏ;
    private TextView ˏॱ;
    private View ˑ;
    private LinearLayout ͺ;
    private TextView ͺॱ;
    private UserCommentInfoCardBean ॱʼ;
    private RatingBar ॱˊ;
    private LinearLayout ॱˋ;
    private TextView ॱˎ;
    private CommentInfo ॱͺ;
    private View ॱॱ;
    private LinearLayout ॱᐝ;
    private FoldTextView ᐝ;
    private TextView ᐝॱ;

    public UserCommentInfoCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ॱ(view.findViewById(bcg.e.ˏˎ));
        ˋ((FoldTextView) view.findViewById(bcg.e.ॱʼ));
        ˋ((RatingBar) view.findViewById(bcg.e.ᐨ));
        ˊ(view.findViewById(bcg.e.ᐧ));
        ˎ((LinearLayout) view.findViewById(bcg.e.ᐝˊ));
        ˏ((LinearLayout) view.findViewById(bcg.e.ͺॱ));
        ˏ((TextView) view.findViewById(bcg.e.ॱʽ));
        ॱ((LinearLayout) view.findViewById(bcg.e.ˑ));
        ˋ((TextView) view.findViewById(bcg.e.ˏˏ));
        ˋ((LinearLayout) view.findViewById(bcg.e.ॱʻ));
        ˎ((TextView) view.findViewById(bcg.e.ॱͺ));
        this.ˏˎ = (ImageView) view.findViewById(bcg.e.ˊʿ);
        this.ˎˏ = view.findViewById(bcg.e.ˊʼ);
        this.ˏॱ = (TextView) view.findViewById(bcg.e.ˊˊ);
        this.ˏˏ = (TextView) view.findViewById(bcg.e.ᐝˋ);
        this.ˋˋ = (TextView) view.findViewById(bcg.e.ˊˑ);
        this.ʻ = (ImageView) view.findViewById(bcg.e.ˊʻ);
        this.ʼ = (ImageView) view.findViewById(bcg.e.ˏͺ);
        this.ʽ = (ImageView) view.findViewById(bcg.e.ॱʾ);
        this.ˋ = view.findViewById(bcg.e.ᐝʽ);
        this.ˎˎ = (HwTextView) view.findViewById(bcg.e.ﾟॱ);
        this.ˍ = (ImageView) view.findViewById(bcg.e.ˎˎ);
        this.ˋᐝ = (TextView) view.findViewById(bcg.e.ʻ);
        this.ˌ = (TextView) view.findViewById(bcg.e.ˏॱ);
        this.ͺॱ = (TextView) view.findViewById(bcg.e.ᐝ);
        this.ᐝ.setOnMaxLineListener(this, this.ˎˎ);
        this.ᐝ.setOnContentChangedListener(this, this.ˎˎ);
        this.ˎˎ.setOnClickListener(this);
        this.ˑ = view.findViewById(bcg.e.ˍ);
        LayoutParams layoutParams = (LayoutParams) this.ॱॱ.getLayoutParams();
        Context context = this.ॱॱ.getContext();
        layoutParams.setMarginStart((context.getResources().getDimensionPixelSize(bcg.b.ͺ) * 2) + context.getResources().getDimensionPixelSize(bcg.b.ˋॱ));
        ʽ(view);
        return this;
    }

    private void ॱ(View view) {
        this.ॱॱ = view;
    }

    public FoldTextView ˋ() {
        return this.ᐝ;
    }

    private void ˋ(FoldTextView foldTextView) {
        this.ᐝ = foldTextView;
    }

    private void ˋ(RatingBar ratingBar) {
        this.ॱˊ = ratingBar;
    }

    private void ˊ(View view) {
        this.ˋॱ = view;
    }

    public View ॱ() {
        return this.ˋॱ;
    }

    public LinearLayout ˊ() {
        return this.ͺ;
    }

    private void ˎ(LinearLayout linearLayout) {
        this.ͺ = linearLayout;
    }

    private void ˏ(TextView textView) {
        this.ˊॱ = textView;
    }

    public LinearLayout ˏ() {
        return this.ʻॱ;
    }

    private void ॱ(LinearLayout linearLayout) {
        this.ʻॱ = linearLayout;
    }

    public LinearLayout ˎ() {
        return this.ॱᐝ;
    }

    public void ˋ(LinearLayout linearLayout) {
        this.ॱᐝ = linearLayout;
    }

    public LinearLayout ᐝ() {
        return this.ॱˋ;
    }

    private void ˏ(LinearLayout linearLayout) {
        this.ॱˋ = linearLayout;
    }

    public TextView ʼ() {
        return this.ॱˎ;
    }

    private void ˋ(TextView textView) {
        this.ॱˎ = textView;
    }

    public TextView ॱॱ() {
        return this.ᐝॱ;
    }

    public void ˎ(TextView textView) {
        this.ᐝॱ = textView;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        this.ˋ.setVisibility(ˊᐝ() ? 0 : 4);
        if (cardBean instanceof UserCommentInfoCardBean) {
            this.ॱʼ = (UserCommentInfoCardBean) cardBean;
            this.ॱͺ = this.ॱʼ.ˊ();
            ˋ(this.ॱʼ);
        }
    }

    private void ˋ(UserCommentInfoCardBean userCommentInfoCardBean) {
        ˏ(userCommentInfoCardBean);
        ʻ();
        ॱ(this.ॱͺ.ॱˋ(), this.ॱͺ.ॱˎ());
        float f = 0.0f;
        try {
            if (!TextUtils.isEmpty(this.ॱͺ.ʼ())) {
                f = Float.parseFloat(this.ॱͺ.ʼ());
            }
        } catch (NumberFormatException e) {
            bcb.ˋ.ˏ("", "rating value error, rating:" + this.ॱͺ.ʼ() + e.toString());
        }
        this.ॱˊ.setRating(f);
        ˎ(this.ˏˏ, bei.ॱ(this.ʼॱ, this.ॱͺ.ʻ()));
        ॱ(userCommentInfoCardBean);
        ˎ(userCommentInfoCardBean);
        ˋ(this.ˊॱ, userCommentInfoCardBean.ˊ().ˋॱ(), this.ˊॱ.getContext().getString(h.ˎͺ));
        if (userCommentInfoCardBean.ˊ().ˋॱ() != 0) {
            this.ʽ.setContentDescription(this.ˊॱ.getContext().getString(h.ˎͺ));
        } else {
            this.ʽ.setContentDescription(null);
        }
        if (userCommentInfoCardBean.ˏ() != 0) {
            this.ॱˋ.setVisibility(8);
            azb.ˋ(this.ͺ, 0, this.ʼॱ.getResources().getDimensionPixelSize(bcg.b.ʼ));
        } else {
            this.ॱˋ.setVisibility(0);
        }
        ॱˊ();
        ˏॱ();
    }

    private void ʻ() {
        String ˏ = this.ॱͺ.ˏ();
        if (TextUtils.isEmpty(ˏ)) {
            this.ˏˎ.setImageResource(c.ᐝॱ);
            this.ˏˎ.setTag("");
        } else if (!ˏ.equals((String) this.ˏˎ.getTag())) {
            this.ˏˎ.setTag(ˏ);
            cea.ˏ(this.ˏˎ, ˏ, "head_default_icon");
        }
        ˎ(this.ˋˋ, this.ॱͺ.ᐝ());
    }

    private void ˎ(UserCommentInfoCardBean userCommentInfoCardBean) {
        CharSequence string = this.ᐝॱ.getContext().getString(h.ᐝˊ);
        if (userCommentInfoCardBean.ˊ().ˊॱ() > 0) {
            ˎ(this.ᐝॱ, cgy.ˎ((double) userCommentInfoCardBean.ˊ().ˊॱ()));
            this.ʼ.setContentDescription(string);
        } else {
            this.ʼ.setContentDescription(null);
            this.ᐝॱ.setText(string);
        }
        string = this.ॱˎ.getContext().getString(h.ㆍ);
        if (userCommentInfoCardBean.ˊ().ॱॱ() > 0) {
            ˎ(this.ॱˎ, cgy.ˎ((double) userCommentInfoCardBean.ˊ().ॱॱ()));
            this.ʻ.setContentDescription(string);
            return;
        }
        this.ʻ.setContentDescription(null);
        this.ॱˎ.setText(string);
    }

    private void ॱˊ() {
        cea.ˎ(this.ˍ, this.ॱʼ.ॱˌ(), c.ʽ);
        ˎ(this.ˋᐝ, this.ॱʼ.ॱ());
        ˎ(this.ˌ, this.ॱͺ.ᐝॱ());
        this.ͺॱ.setText(this.ॱͺ.ʾ() + ContentManager.getInstant().getContext().getResources().getString(h.ᴵ));
    }

    private void ˏॱ() {
        int ʻॱ = this.ॱͺ.ʻॱ();
        if (ʻॱ == 4) {
            this.ˏॱ.setText(h.ॱॱ);
            this.ˑ.setVisibility(0);
        } else if (ʻॱ == 3) {
            this.ˏॱ.setText(h.ˍ);
            this.ˑ.setVisibility(0);
        } else {
            this.ˑ.setVisibility(8);
        }
    }

    private void ॱ(UserCommentInfoCardBean userCommentInfoCardBean) {
        if (userCommentInfoCardBean.ˊ().ͺ() == 1) {
            this.ʼ.setBackgroundResource(c.ͺ);
        } else {
            this.ʼ.setBackgroundResource(c.ʼ);
        }
        if (userCommentInfoCardBean.ˊ().ˏॱ() == 1) {
            this.ʻ.setBackgroundResource(c.ˎ);
        } else {
            this.ʻ.setBackgroundResource(c.ˏ);
        }
    }

    private void ˏ(UserCommentInfoCardBean userCommentInfoCardBean) {
        int i = 0;
        if (ˊᐝ()) {
            this.ˋ.setVisibility(0);
        } else {
            this.ˋ.setVisibility(8);
        }
        LayoutParams layoutParams = (LayoutParams) this.ˎˏ.getLayoutParams();
        if (!userCommentInfoCardBean.ॱˍ()) {
            i = (int) this.ʼॱ.getResources().getDimension(bcg.b.ˏ);
        }
        layoutParams.topMargin = i;
        this.ˎˏ.setLayoutParams(layoutParams);
    }

    private void ˎ(TextView textView, String str) {
        if (TextUtils.isEmpty(str)) {
            textView.setVisibility(8);
            return;
        }
        textView.setVisibility(0);
        textView.setText(str);
    }

    private void ˋ(TextView textView, int i, String str) {
        if (i != 0) {
            textView.setVisibility(0);
            textView.setText(cgy.ˎ((double) i));
            return;
        }
        textView.setVisibility(0);
        textView.setText(str);
    }

    private void ॱ(String str, boolean z) {
        if (TextUtils.isEmpty(str)) {
            this.ᐝ.setVisibility(8);
            return;
        }
        this.ᐝ.setVisibility(0);
        if (z) {
            this.ˎˎ.setText(this.ˎˎ.getContext().getString(h.ॱꜞ));
        } else {
            this.ˎˎ.setText(this.ˎˎ.getContext().getString(h.ॱﾞ));
        }
        this.ᐝ.setContent(new SpannableStringBuilder(str), z, ber.ॱ(this.ᐝ));
    }

    public void ॱ(boolean z, HwTextView hwTextView) {
        if (hwTextView == null) {
            return;
        }
        if (z) {
            hwTextView.setVisibility(0);
        } else {
            hwTextView.setVisibility(8);
        }
    }

    public void ˊ(boolean z, HwTextView hwTextView) {
        if (hwTextView == null) {
            return;
        }
        if (z) {
            hwTextView.setText(hwTextView.getContext().getString(h.ॱꜞ));
        } else {
            hwTextView.setText(hwTextView.getContext().getString(h.ॱﾞ));
        }
    }

    public void onClick(View view) {
        if (view.getId() == bcg.e.ﾟॱ) {
            this.ᐝ.ॱ();
            this.ॱͺ.ˋ(this.ᐝ.ˏ());
        }
    }
}
